#include<cstdio>
#include<cstring>
#include<cstdlib>
const int MAX=2100000000;
int n,m,count=0;
int f[201][21][801],t[201],s[201];
bool ansp[201],path[201][21][801];
int max(int x,int y)
{
	return x>y?x:y;
}
int min(int x,int y)
{
	return x<y?x:y;
}
int abs(int x)
{
	if(x<0)return x*(-1);
	else return x;
}
int main()
{
	freopen("test.in","r",stdin);
	scanf("%d%d",&n,&m);
	while(n!=0&&m!=0)
	{
		count++;
		memset(path,false,sizeof(path));
		memset(ansp,false,sizeof(ansp));
		for(int i=1;i<=n;i++)
		{
			int a, b;
			scanf("%d%d",&a,&b);
			t[i]=a-b;
			s[i]=a+b;
		}
//		memset(f,0,sizeof(f));
		for(int i=0;i<=n;i++)
		   for(int j=0;j<=m;j++)
			   for(int k=0;k<=800;k++)
				f[i][j][k]=-1*MAX;
		for(int i=1;i<=n;i++)
			f[i][0][400]=0;
			   
		f[1][1][t[1]+400]=s[1];path[1][1][t[1]+400]=true;
		int tem=t[1]+400;
		for(int i=2;i<=m;i++)
		{
			f[i][i][tem+t[i]]=f[i-1][i-1][tem]+s[i];
			path[i][i][tem+t[i]]=true;
			tem+=t[i];
		}
		for(int i=2;i<=n;i++)
			for(int j=1;j<=m&&j<i;j++)
			   for(int k=0;k<=800;k++)
			   {
				   if(k-t[i]>=0&&f[i-1][j][k]<=f[i-1][j-1][k-t[i]]+s[i])	
				   {
					   f[i][j][k]=f[i-1][j-1][k-t[i]]+s[i];
					   path[i][j][k]=true;
				   }
					else f[i][j][k]=f[i-1][j][k];
			   }
		int ans1=0,ans2=0,tem2=-1;
		tem=-1;
		for(int i=400;i<=800;i++)
		{
			if(f[n][m][i]>=0)
			{
				tem=i;							
			}
			if(f[n][m][800-i]>=0)
			{
				tem2=800-i;
			}
			if(tem!=-1&&tem2!=-1)
			{tem=f[n][m][i]>f[n][m][800-i]?i:800-i;break;}
			if(tem!=-1)break;
			if(tem2!=-1){tem=800-i;break;}
		}
//		printf("%d %d\n",anssub,anssum);
		int i=n,j=m,k=tem;
		while(j>0)
		{
			if(path[i][j][k])
			{
				ansp[i]=true;
				ans1+=(t[i]+s[i])/2;
				ans2+=(s[i]-t[i])/2;
				k-=t[i];i--;j--;
			}
			else i--;
		}
		printf("Jury #%d \nBest jury has value %d for prosecution and value %d for defence: \n",count,ans1,ans2);
		for(int i=1;i<=n;i++)
			if(ansp[i])printf(" %d",i);
		printf(" \n");
		scanf("%d%d",&n,&m);
	}
	return 0;
}
